package com.qd.common.panda.domain.entity.transfer;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Optional;

/**
 * 已分账信息
 *
 * @author sjk
 * @create 2023-09-07 10:54
 * @since 1.0.0
 */
@Getter
@Setter
@Accessors(chain = true)
public class UserDividedDTO extends BaseQuery {
    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE = "已分账信息";
    /**
     * 收款用户ID
     */
    @ExcelProperty(value = {EXCEL_TITLE, "用户ID"})
    private String userId;
    /**
     * 收款用户名
     */
    @ExcelProperty(value = {EXCEL_TITLE, "用户名"})
    private String userName;
    /**
     * 收款人手机号
     */
    @ExcelProperty(value = {EXCEL_TITLE, "手机号"})
    private String mobile;
    /**
     * 收款卡号
     */
    @ExcelProperty(value = {EXCEL_TITLE, "卡号"})
    private String cardNumber;
    /**
     * 开户银行
     */
    @ExcelProperty(value = {EXCEL_TITLE, "开户银行"})
    private String openBank;
    /**
     * 已转账金额
     */
    @JsonIgnore
    @ExcelIgnore
    private BigDecimal transferAmount;
    /**
     * 已转账金额显示
     */
    @ExcelProperty(value = {EXCEL_TITLE, "已转账金额"})
    private String transferAmountDisplay;

    public String getTransferAmountDisplay() {
        return Optional.ofNullable(transferAmount).orElse(new BigDecimal("0")).stripTrailingZeros().toPlainString();
    }

    @Override
    public void freeData() {
        this.userId =null;
        this.userName =null;
        this.mobile =null;
        this.cardNumber =null;
        this.openBank =null;
        this.transferAmount =null;
        this.transferAmountDisplay =null;
        super.freeData();
    }
}